package com.niji.littly_donkey_android.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;
import com.android.volley.*;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.adapter.CommentFabulousAdapter;
import com.niji.littly_donkey_android.adapter.OrderAdapter;
import com.niji.littly_donkey_android.bean.CommentFabulous;
import com.niji.littly_donkey_android.bean.Order;
import com.niji.littly_donkey_android.http.ConnectViaSession;
import com.niji.littly_donkey_android.util.JsonUtil;
import com.niji.littly_donkey_android.util.StatusBarUtil;
import com.niji.littly_donkey_android.util.UrlUtil;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MyAllOrderActivity extends BaseActivity {

    private static final String TAG = "MyAllOrderActivity";


    private Button my_order_all_return;

    private Button my_order_all_order_details;

    private Button order_comment;

    private TextView order_all_change;

    private TextView order_paid_change;

    private TextView order_checked_change;

    private TextView order_commented_change;

    private TextView order_refund_change;

    private ImageView order_all_img;

    private ImageView order_paid_img;

    private ImageView order_checked_img;

    private ImageView order_commented_img;

    private ImageView order_refund_img;



    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_order_all_activity);
        init();
        allOrderChange();
        paidOrderChange();
        checkedOrderChange();
        commentedOrderChange();
        refundOrderChange();
        myOrderAllReturn();
        myOrderAllOrderDetails();
        orderComment();
//        orderListMethod();

    }

    /**
     * 订单列表事件
     */
    private void orderListMethod() {
        ListView order_list = findViewById(R.id.order_list);
        order_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Button order_btn1 = view.findViewById(R.id.order_btn1);
                Button order_btn2 = view.findViewById(R.id.order_btn2);
                TextView order_id = view.findViewById(R.id.order_id);
                order_btn2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String btnName2 = order_btn2.getText().toString().trim();
                        if(btnName2.equals("取消订单")){
                            //取消订单
                            cancelOrder(Integer.parseInt(order_id.getText().toString().trim()));
                        }else if(btnName2.equals("退款")){
                            refund(Integer.parseInt(order_id.getText().toString().trim()));
                        }else if(btnName2.equals("评价")){
                            Intent intent = new Intent(MyAllOrderActivity.this, OrderCommentActivity.class);
                            intent.putExtra("order_id",order_id.getText().toString().trim());
                            startActivity(intent);
                        }
                    }
                });

                order_btn1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String btnName1 = order_btn1.getText().toString().trim();
                        if(btnName1.equals("付款")){
                            //取消订单
                            Intent intent = new Intent(MyAllOrderActivity.this, OrderFillActivity.class);
                            intent.putExtra("attractions_id","1");
                            startActivity(intent);
                        }else if(btnName1.equals("查看订单")){
                            Intent intent = new Intent(MyAllOrderActivity.this, OrderDetailsActivity.class);
                            intent.putExtra("order_id","1");
                            startActivity(intent);
                        }else if(btnName1.equals("再次购买")){
                            Intent intent = new Intent(MyAllOrderActivity.this, OrderFillActivity.class);
                            intent.putExtra("attractions_id","1");
                            startActivity(intent);
                        }
                    }
                });
            }
        });
    }



    /**
     * 退款
     */
    private void refund(int id) {
        String url = UrlUtil.URL + "/order/edit";
        RequestQueue requestQueue= Volley.newRequestQueue(MyAllOrderActivity.this);
        StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String s) {
                try {
                    Map<String, Object> map = JsonUtil.jsonToMap(s);
                    Integer code = (Integer) map.get("code");
                    if (code == 0) {
                        String  data = (String) map.get("data");
                        Log.i(TAG,data.toString());
                        Toast.makeText(MyAllOrderActivity.this, data, Toast.LENGTH_LONG).show();


                    } else if(code == -1){
                        Toast.makeText(MyAllOrderActivity.this, "登录失效，请重新登录", Toast.LENGTH_LONG).show();
                        Intent intent = new Intent(MyAllOrderActivity.this, GetPhoneCodeActivity.class);
                        intent.putExtra("loginCode","-1");
                        startActivity(intent);
                        finish();
                    }else {
                        String  data = (String) map.get("message");
                        Toast.makeText(MyAllOrderActivity.this, data, Toast.LENGTH_SHORT).show();
                        overridePendingTransition(R.anim.xpage_slide_in_left, R.anim.xpage_slide_out_right);
                        finish();
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                Log.e(TAG, volleyError.getMessage(), volleyError);
            }
        }) {

            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> map = new HashMap<>();
                map.put("order_id",String.valueOf(id));
                map.put("type",String.valueOf(2));
                map.put("number",String.valueOf(1));
                return map;
            }

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                String sesseionid = new ConnectViaSession(MyAllOrderActivity.this).GetSession();
                if (!sesseionid.equals("")) {
                    HashMap<String, String> headers = new HashMap<String, String>();
                    headers.put("cookie", sesseionid);
                    return headers;
                } else {
                    return super.getHeaders();
                }
            }
        };
        requestQueue.add(stringRequest);

    }

    /**
     * 取消订单
     * @param id
     */
    private void cancelOrder(int id) {
        String url = UrlUtil.URL + "/order/cancel";
        RequestQueue requestQueue= Volley.newRequestQueue(MyAllOrderActivity.this);
        StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String s) {
                try {
                    Map<String, Object> map = JsonUtil.jsonToMap(s);
                    Integer code = (Integer) map.get("code");
                    if (code == 0) {
                        String  data = (String) map.get("data");
                        Log.i(TAG,data.toString());
                        Toast.makeText(MyAllOrderActivity.this, data, Toast.LENGTH_LONG).show();


                    } else if(code == -1){
                        Toast.makeText(MyAllOrderActivity.this, "登录失效，请重新登录", Toast.LENGTH_LONG).show();
                        Intent intent = new Intent(MyAllOrderActivity.this, GetPhoneCodeActivity.class);
                        intent.putExtra("loginCode","-1");
                        startActivity(intent);
                        finish();
                    }else {
                        String  data = (String) map.get("message");
                        Toast.makeText(MyAllOrderActivity.this, data, Toast.LENGTH_SHORT).show();
                        overridePendingTransition(R.anim.xpage_slide_in_left, R.anim.xpage_slide_out_right);
                        finish();
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                Log.e(TAG, volleyError.getMessage(), volleyError);
            }
        }) {

            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> map = new HashMap<>();
                map.put("order_id",String.valueOf(id));
                return map;
            }

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                String sesseionid = new ConnectViaSession(MyAllOrderActivity.this).GetSession();
                if (!sesseionid.equals("")) {
                    HashMap<String, String> headers = new HashMap<String, String>();
                    headers.put("cookie", sesseionid);
                    return headers;
                } else {
                    return super.getHeaders();
                }
            }
        };
        requestQueue.add(stringRequest);

    }

    /**
     * 切换退款
     */
    private void refundOrderChange() {
        order_refund_change.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                order_all_change.setTextColor(Color.parseColor("#999999"));
                order_paid_change.setTextColor(Color.parseColor("#999999"));
                order_checked_change.setTextColor(Color.parseColor("#999999"));
                order_commented_change.setTextColor(Color.parseColor("#999999"));
                order_refund_change.setTextColor(Color.parseColor("#333333"));
                order_all_img.setVisibility(View.INVISIBLE);
                order_paid_img.setVisibility(View.INVISIBLE);
                order_checked_img.setVisibility(View.INVISIBLE);
                order_commented_img.setVisibility(View.INVISIBLE);
                order_refund_img.setVisibility(View.VISIBLE);
                showOrders(4);
            }
        });
    }

    /**
     * 切换待评价
     */
    private void commentedOrderChange() {
        order_commented_change.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                order_all_change.setTextColor(Color.parseColor("#999999"));
                order_paid_change.setTextColor(Color.parseColor("#999999"));
                order_checked_change.setTextColor(Color.parseColor("#999999"));
                order_commented_change.setTextColor(Color.parseColor("#333333"));
                order_refund_change.setTextColor(Color.parseColor("#999999"));
                order_all_img.setVisibility(View.INVISIBLE);
                order_paid_img.setVisibility(View.INVISIBLE);
                order_checked_img.setVisibility(View.INVISIBLE);
                order_commented_img.setVisibility(View.VISIBLE);
                order_refund_img.setVisibility(View.INVISIBLE);
                showOrders(3);
            }
        });
    }

    /**
     * 切换待检票
     */
    private void checkedOrderChange() {
        order_checked_change.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                order_all_change.setTextColor(Color.parseColor("#999999"));
                order_paid_change.setTextColor(Color.parseColor("#999999"));
                order_checked_change.setTextColor(Color.parseColor("#333333"));
                order_commented_change.setTextColor(Color.parseColor("#999999"));
                order_refund_change.setTextColor(Color.parseColor("#999999"));
                order_all_img.setVisibility(View.INVISIBLE);
                order_paid_img.setVisibility(View.INVISIBLE);
                order_checked_img.setVisibility(View.VISIBLE);
                order_commented_img.setVisibility(View.INVISIBLE);
                order_refund_img.setVisibility(View.INVISIBLE);
                showOrders(2);
            }
        });
    }

    /**
     * 切换待付款
     */
    private void paidOrderChange() {
        order_paid_change.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                order_all_change.setTextColor(Color.parseColor("#999999"));
                order_paid_change.setTextColor(Color.parseColor("#333333"));
                order_checked_change.setTextColor(Color.parseColor("#999999"));
                order_commented_change.setTextColor(Color.parseColor("#999999"));
                order_refund_change.setTextColor(Color.parseColor("#999999"));
                order_all_img.setVisibility(View.INVISIBLE);
                order_paid_img.setVisibility(View.VISIBLE);
                order_checked_img.setVisibility(View.INVISIBLE);
                order_commented_img.setVisibility(View.INVISIBLE);
                order_refund_img.setVisibility(View.INVISIBLE);
                showOrders(1);
            }
        });
    }

    /**
     * 切换全部
     */
    private void allOrderChange() {
        order_all_change.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                order_all_change.setTextColor(Color.parseColor("#333333"));
                order_paid_change.setTextColor(Color.parseColor("#999999"));
                order_checked_change.setTextColor(Color.parseColor("#999999"));
                order_commented_change.setTextColor(Color.parseColor("#999999"));
                order_refund_change.setTextColor(Color.parseColor("#999999"));
                order_all_img.setVisibility(View.VISIBLE);
                order_paid_img.setVisibility(View.INVISIBLE);
                order_checked_img.setVisibility(View.INVISIBLE);
                order_commented_img.setVisibility(View.INVISIBLE);
                order_refund_img.setVisibility(View.INVISIBLE);
                showAllOrders();
            }
        });
    }

    private void init() {
        order_all_change = findViewById(R.id.order_all_change);
        order_paid_change = findViewById(R.id.order_paid_change);
        order_checked_change = findViewById(R.id.order_checked_change);
        order_commented_change = findViewById(R.id.order_commented_change);
        order_refund_change = findViewById(R.id.order_refund_change);
        order_all_img = findViewById(R.id.order_all_img);
        order_paid_img = findViewById(R.id.order_paid_img);
        order_checked_img = findViewById(R.id.order_checked_img);
        order_commented_img = findViewById(R.id.order_commented_img);
        order_refund_img = findViewById(R.id.order_refund_img);
        Intent intent = getIntent();
        String orderStatus = intent.getStringExtra("orderStatus");
        if(orderStatus == null){
            order_all_change.setTextColor(Color.parseColor("#333333"));
            order_paid_change.setTextColor(Color.parseColor("#999999"));
            order_checked_change.setTextColor(Color.parseColor("#999999"));
            order_commented_change.setTextColor(Color.parseColor("#999999"));
            order_refund_change.setTextColor(Color.parseColor("#999999"));
            order_all_img.setVisibility(View.VISIBLE);
            order_paid_img.setVisibility(View.INVISIBLE);
            order_checked_img.setVisibility(View.INVISIBLE);
            order_commented_img.setVisibility(View.INVISIBLE);
            order_refund_img.setVisibility(View.INVISIBLE);
            showAllOrders();
        } else if(orderStatus.equals("1")){
            order_all_change.setTextColor(Color.parseColor("#999999"));
            order_paid_change.setTextColor(Color.parseColor("#333333"));
            order_checked_change.setTextColor(Color.parseColor("#999999"));
            order_commented_change.setTextColor(Color.parseColor("#999999"));
            order_refund_change.setTextColor(Color.parseColor("#999999"));
            order_all_img.setVisibility(View.INVISIBLE);
            order_paid_img.setVisibility(View.VISIBLE);
            order_checked_img.setVisibility(View.INVISIBLE);
            order_commented_img.setVisibility(View.INVISIBLE);
            order_refund_img.setVisibility(View.INVISIBLE);
            showOrders(1);
        }else if(orderStatus.equals("2")){
            order_all_change.setTextColor(Color.parseColor("#999999"));
            order_paid_change.setTextColor(Color.parseColor("#999999"));
            order_checked_change.setTextColor(Color.parseColor("#333333"));
            order_commented_change.setTextColor(Color.parseColor("#999999"));
            order_refund_change.setTextColor(Color.parseColor("#999999"));
            order_all_img.setVisibility(View.INVISIBLE);
            order_paid_img.setVisibility(View.INVISIBLE);
            order_checked_img.setVisibility(View.VISIBLE);
            order_commented_img.setVisibility(View.INVISIBLE);
            order_refund_img.setVisibility(View.INVISIBLE);
            showOrders(2);
        }else if(orderStatus.equals("3")){
            order_all_change.setTextColor(Color.parseColor("#999999"));
            order_paid_change.setTextColor(Color.parseColor("#999999"));
            order_checked_change.setTextColor(Color.parseColor("#999999"));
            order_commented_change.setTextColor(Color.parseColor("#333333"));
            order_refund_change.setTextColor(Color.parseColor("#999999"));
            order_all_img.setVisibility(View.INVISIBLE);
            order_paid_img.setVisibility(View.INVISIBLE);
            order_checked_img.setVisibility(View.INVISIBLE);
            order_commented_img.setVisibility(View.VISIBLE);
            order_refund_img.setVisibility(View.INVISIBLE);
            showOrders(3);
        }else if(orderStatus.equals("4")){
            order_all_change.setTextColor(Color.parseColor("#999999"));
            order_paid_change.setTextColor(Color.parseColor("#999999"));
            order_checked_change.setTextColor(Color.parseColor("#999999"));
            order_commented_change.setTextColor(Color.parseColor("#999999"));
            order_refund_change.setTextColor(Color.parseColor("#333333"));
            order_all_img.setVisibility(View.INVISIBLE);
            order_paid_img.setVisibility(View.INVISIBLE);
            order_checked_img.setVisibility(View.INVISIBLE);
            order_commented_img.setVisibility(View.INVISIBLE);
            order_refund_img.setVisibility(View.VISIBLE);
            showOrders(4);
        }
    }

    /**
     * 全部订单
     */
    private void showAllOrders() {
        ListView order_list = findViewById(R.id.order_list);
        ArrayList<Order> orders = new ArrayList<Order>();
        String url = UrlUtil.URL + "/order/list?page=1&per_page=100";
        RequestQueue requestQueue= Volley.newRequestQueue(MyAllOrderActivity.this);
        StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String s) {
                try {
                    Map<String, Object> map = JsonUtil.jsonToMap(s);
                    Integer code = (Integer) map.get("code");
                    if (code == 0) {
                        Map<String,Object> dataMap = (Map) map.get("data");
                        Log.i(TAG,dataMap.toString());
                        List<Map<String, Object>> mapList = (List<Map<String, Object>>) dataMap.get("data");
                        Log.i(TAG,mapList.toString());
                        for (int i = 0; i < mapList.size(); i++) {
                            Order order = new Order();
                            Integer id = (Integer) mapList.get(i).get("id");
                            Integer user_id = (Integer) mapList.get(i).get("user_id");
                            Integer attractions_id = (Integer) mapList.get(i).get("attractions_id");
                            String numbering = (String) mapList.get(i).get("numbering");
                            Integer tickets_number = (Integer) mapList.get(i).get("tickets_number");
                            String price = (String) mapList.get(i).get("price");
                            Integer status = (Integer) mapList.get(i).get("status");
                            String order_time = (String) mapList.get(i).get("order_time");
                            String subscribe_time = (String) mapList.get(i).get("subscribe_time");
                            String attractionsName = (String) mapList.get(i).get("attractionsName");
                            String photo = (String) mapList.get(i).get("photo");
                            String statusName = (String) mapList.get(i).get("statusName");
                            order.setId(id);
                            order.setUserId(user_id);
                            order.setAttractionsId(attractions_id);
                            order.setNumber(numbering);
                            order.setTicketsNumber(tickets_number);
                            order.setPrice(price);
                            order.setStatus(status);
                            order.setOrderTime(order_time);
                            order.setSubscribeTime(subscribe_time);
                            order.setAttractionsName(attractionsName);
                            order.setPhoto(photo);
                            order.setStatusName(statusName);
                            orders.add(order);

                        }

                    } else if(code == -1){
                        Toast.makeText(MyAllOrderActivity.this, "登录失效，请重新登录", Toast.LENGTH_LONG).show();
                        Intent intent = new Intent(MyAllOrderActivity.this, GetPhoneCodeActivity.class);
                        intent.putExtra("loginCode","-1");
                        startActivity(intent);
                        finish();
                    }else {
                        Toast.makeText(MyAllOrderActivity.this, "全部订单列表获取失败", Toast.LENGTH_SHORT).show();
                        overridePendingTransition(R.anim.xpage_slide_in_left, R.anim.xpage_slide_out_right);
                        finish();
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                order_list.setAdapter(new OrderAdapter(MyAllOrderActivity.this,orders));
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                Log.e(TAG, volleyError.getMessage(), volleyError);
            }
        }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                String sesseionid = new ConnectViaSession(MyAllOrderActivity.this).GetSession();
                if (!sesseionid.equals("")) {
                    HashMap<String, String> headers = new HashMap<String, String>();
                    headers.put("cookie", sesseionid);
                    return headers;
                } else {
                    return super.getHeaders();
                }
            }
        };

        requestQueue.add(stringRequest);
    }

    /**
     * 其他订单
     */
    private void showOrders(Integer status) {
        ListView order_list = findViewById(R.id.order_list);
        ArrayList<Order> orders = new ArrayList<Order>();
        String url = UrlUtil.URL + "/order/list?page=1&per_page=50&status=" + status;
        RequestQueue requestQueue= Volley.newRequestQueue(MyAllOrderActivity.this);
        StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String s) {
                try {
                    Map<String, Object> map = JsonUtil.jsonToMap(s);
                    Integer code = (Integer) map.get("code");
                    if (code == 0) {
                        Map<String,Object> dataMap = (Map) map.get("data");
                        Log.i(TAG,dataMap.toString());
                        List<Map<String, Object>> mapList = (List<Map<String, Object>>) dataMap.get("data");
                        Log.i(TAG,mapList.toString());
                        for (int i = 0; i < mapList.size(); i++) {
                            Order order = new Order();
                            Integer id = (Integer) mapList.get(i).get("id");
                            Integer user_id = (Integer) mapList.get(i).get("user_id");
                            Integer attractions_id = (Integer) mapList.get(i).get("attractions_id");
                            String numbering = (String) mapList.get(i).get("numbering");
                            Integer tickets_number = (Integer) mapList.get(i).get("tickets_number");
                            String price = (String) mapList.get(i).get("price");
                            Integer status = (Integer) mapList.get(i).get("status");
                            String order_time = (String) mapList.get(i).get("order_time");
                            String subscribe_time = (String) mapList.get(i).get("subscribe_time");
                            String attractionsName = (String) mapList.get(i).get("attractionsName");
                            String photo = (String) mapList.get(i).get("photo");
                            String statusName = (String) mapList.get(i).get("statusName");
                            order.setId(id);
                            order.setUserId(user_id);
                            order.setAttractionsId(attractions_id);
                            order.setNumber(numbering);
                            order.setTicketsNumber(tickets_number);
                            order.setPrice(price);
                            order.setStatus(status);
                            order.setOrderTime(order_time);
                            order.setSubscribeTime(subscribe_time);
                            order.setAttractionsName(attractionsName);
                            order.setPhoto(photo);
                            order.setStatusName(statusName);
                            orders.add(order);

                        }

                    } else {
                        Toast.makeText(MyAllOrderActivity.this, "全部订单列表获取失败", Toast.LENGTH_SHORT).show();
                        overridePendingTransition(R.anim.xpage_slide_in_left, R.anim.xpage_slide_out_right);
                        finish();
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                order_list.setAdapter(new OrderAdapter(MyAllOrderActivity.this,orders));
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                Log.e(TAG, volleyError.getMessage(), volleyError);
            }
        }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                String sesseionid = new ConnectViaSession(MyAllOrderActivity.this).GetSession();
                if (!sesseionid.equals("")) {
                    HashMap<String, String> headers = new HashMap<String, String>();
                    headers.put("cookie", sesseionid);
                    return headers;
                } else {
                    return super.getHeaders();
                }
            }
        };

        requestQueue.add(stringRequest);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.my_order_all_activity;

    }
    @Override
    protected int getStatusBarColor() {
        return R.color.white_easy_photos;
    }

    /***
     * 评价
     */
    private void orderComment() {

    }

    /**
     * 查看订单
     */
    private void myOrderAllOrderDetails() {

    }

    private void myOrderAllReturn() {
        my_order_all_return = findViewById(R.id.my_order_all_return);
        my_order_all_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                overridePendingTransition(R.anim.xpage_slide_in_left,R.anim.xpage_slide_out_right);
                finish();
            }
        });
    }





}
